home *** CD-ROM | disk | FTP | other *** search
- Path: theory.lcs.mit.edu!wald
- From: wald@theory.lcs.mit.edu (David Wald)
- Newsgroups: comp.sys.sgi.apps,comp.lang.c++
- Subject: Re: SGI's C++ compiler and the boolean type
- Followup-To: comp.lang.c++
- Date: 11 Apr 1996 14:59:13 GMT
- Organization: Theory of Computation, LCS, MIT
- Message-ID: <WALD.96Apr11105913@woodpecker.lcs.mit.edu>
- References: <4kefm7$oao@ncar.ucar.edu> <4kg6fv$h7k@nic.ftns.no>
- <4khepk$8k1@decaxp.HARVARD.EDU>
- NNTP-Posting-Host: woodpecker.lcs.mit.edu
- In-reply-to: ccshan@scws44.harvard.edu's message of 10 Apr 1996 23:04:20 GMT
-
- In article <4khepk$8k1@decaxp.HARVARD.EDU> ccshan@scws44.harvard.edu
- (Chung-chieh Shan) writes:
- >According to the proposed standard, true is implicitly casted from
- >bool to the integer 1. Nonzero integers are implicitly casted from
- >int to the bool true.
- >
- >Funny nobody has written an implementation of bool. (AFAIK)
-
- That may be because you can't write a class that behaves like the
- draft standard bool type. In the draft standard, all the standard
- boolean operators actually return a bool type, and there's no way to
- produce that effect with a user-defined type. E.g.,
-
- int f(int) { return 1; }
- int f(bool) { return 0; }
- int distinguish() { return f( 0 == 1 ); }
-
- No user-level definition of bool will make distinguish() return 0, as
- it must in the draft standard.
-
- -David
- --
- ============================================================================
- David Wald http://theory.lcs.mit.edu/~wald/ wald@theory.lcs.mit.edu
- ============================================================================
-